<%#
 Copyright 2008 Steven Barth <steven@midlink.org>
 Copyright 2008-2019 Jo-Philipp Wich <jo@mein.io>
 Licensed to the public under the Apache License 2.0.
-%>

<%
	if not luci.dispatcher.context.template_header_sent then
		include("themes/" .. theme .. "/header")
		luci.dispatcher.context.template_header_sent = true
	end

	local applyconf = luci.config and luci.config.apply
%>

<script type="text/javascript" src="<%=resource%>/promis.min.js"></script>
<script type="text/javascript" src="<%=resource%>/luci.js"></script>
<style>
body.modal-overlay-active #modal_overlay {
}

body.modal-overlay-active #modal_overlay > .modal {
	align-items: center;
	box-shadow: 0 0 3px #444;
	display: flex;
	flex-wrap: wrap;
	max-height: unset;
	/* max-width: unset; */
	min-height: 32px;
	min-width: 270px;
	background: #fff;
	border-radius: 3px;
	padding: 1em;
	margin: 0;
	position: absolute;
	top: 15%;
	left: 50%;
	transform: translate(-50%,-15%);
}
</style>
<script src="<%=resource%>/jquery.min.js"></script>
<script type="text/javascript">
	L = new LuCI(<%= luci.http.write_json({
		token          = token,
		media          = media,
		resource       = resource,
		scriptname     = luci.http.getenv("SCRIPT_NAME"),
		pathinfo       = luci.http.getenv("PATH_INFO"),
		documentroot   = luci.http.getenv("DOCUMENT_ROOT"),
		requestpath    = luci.dispatcher.context.requestpath,
		dispatchpath   = luci.dispatcher.context.path,
		pollinterval   = luci.config.main.pollinterval or 5,
		ubuspath       = luci.config.main.ubuspath or '/ubus/',
		sessionid      = luci.dispatcher.context.authsession,
		nodespec       = luci.dispatcher.context.dispatched,
		apply_rollback = applyconf and applyconf.rollback,
		apply_holdoff  = applyconf and applyconf.holdoff,
		apply_timeout  = applyconf and applyconf.timeout,
		apply_display  = applyconf and applyconf.display,
		rollback_token = rollback_token
	}) %>);
</script>
